package mao.leetcode.dp.leetcode198;

public class Solution {

    public int rob(int[] nums) {
        int preMax=0; //-1时为0；
        int curMax = 0;
        for (int x : nums) {
            int temp = Math.max(preMax+x,curMax);
            preMax = curMax;
            curMax = temp;
        }
        return curMax;
    }
}
